home *** CD-ROM | disk | FTP | other *** search
- Path: eccdb1.pms.ford.com!pms991!mbobak
- From: mbobak@pms991.uucp (Mark J. Bobak)
- Newsgroups: comp.unix.programmer,comp.lang.c
- Subject: Re: getpwnam() -error checking
- Date: 4 Apr 1996 17:45:19 GMT
- Organization: Not an Official Spokesperson for Ford Motor Company, Dearborn, MI
- Message-ID: <4k11rf$lav@eccdb1.pms.ford.com>
- References: <Pine.SOL.3.91.960327025242.5526B-100000@ee.tamu.edu>
- NNTP-Posting-Host: pms991.pms.ford.com
-
- In article <Pine.SOL.3.91.960327025242.5526B-100000@ee.tamu.edu>,
- Ajay Kumar Gummadi <ajay@ee.tamu.edu> wrote:
- >
- >Hi all,
- >
- > The function getpwnam() takes the user-id as input argument and returns
- >a pointer to a structure, that contains all the user information.
- >
- > If I give a wrong /non-existent user-id as input argument, how can I
- >check the error condition that may arise, before, the system dumps core.
- >
- > Reply by email will be very helpful.
-
- getpwnam() will return a pointer to a struct passwd on success or a NULL
- on failure. So, just check to see if you were passed a NULL. If you were,
- then the user id probably doesn't exist. (I say probably doesn't exist because
- there may be other error conditions that would cause getpwnam() to return NULL.)
-
- You'd be better off asking this in comp.unix.programmer.
-
- -Mark
- --
- Mark J. Bobak, Application Developer
- Advanced Vehicle & Computer Aided Engineering Systems Department
- Process Leadership, Ford Motor Company
- mbobak@ford.com
-